package com.guohui.feign1.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.guohui.feign1.client.Boot1FeignClient;
import com.guohui.feign1.service.HelloService;

@RestController
public class HelloBootController {

  private Logger logger = LoggerFactory.getLogger(getClass());
  
  @Autowired
  private HelloService helloService;
  
  @Value("${spring.application.name}")
  private String serviceName;
  
  @RequestMapping(value="/helloBoot1",method=RequestMethod.GET)
  public String helloBoot1() throws Exception {
    logger.debug("start to connect boot1");
    String success = helloService.sayHello(serviceName);
    if("success".equals(success)) {
      logger.debug("Connection successful");
    }else {
      logger.debug("Connection failed");
    }
    return "success";
  }
  
  
  @RequestMapping(value="/hello",method= {RequestMethod.GET,RequestMethod.POST})
  public String hello(String client) throws Exception {
    logger.debug(client+" say hello to "+serviceName);
    return "success";
  }
}
